//
//  ZYCScheduleRootSectionHeaderView.m
//  ZDSC
//
//  Created by ZDTX on 2021/7/20.
//

#import "ZYCScheduleRootSectionHeaderView.h"
#import "ZYCAttendanceStatisiticModel.h"
#import "NSDateExtra.h"
#import "ZYCScheduleModel.h"
#import "ZYCTeacherDineListModel.h"


@interface ZYCScheduleRootSectionHeaderView ()


@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIView *pointView;
@property (nonatomic, strong) UILabel *detailLabel;
@end
@implementation ZYCScheduleRootSectionHeaderView


- (void)setColor:(UIColor *)color{
    _color = color;
    _titleLabel.textColor = color;
    _pointView.backgroundColor =  color;
}
- (void)setDModel:(ZYCTeacherDineListModel *)dModel{
    _dModel = dModel;
    _titleLabel.text = dModel.typeName;
    
}

- (void)setDinnerDict:(NSDictionary *)dinnerDict{
    _dinnerDict = dinnerDict;
    _pointView.backgroundColor = dinnerDict[@"color"];
    _titleLabel.text = dinnerDict[@"title"];
}

- (void)setSModel:(ZYCScheduleModel *)sModel{
    _sModel = sModel;

    if (sModel.courseTime.length == 0) {
        _titleLabel.text = @"全天";
        _pointView.backgroundColor = HEX_RGB(@"#B0B0B0");
    }else{
        _titleLabel.text = sModel.courseTime;
        _pointView.backgroundColor = HEX_RGB(@"#FEAC5D");
    }
}
- (void)setModel:(ZYCAttendanceStatisiticModel *)model{
    _model = model;
    _titleLabel.text = [NSString stringWithFormat:@"%@本月考勤",model.studentName];
    NSString *dateStr = [NSString stringWithFormat:@"%@", [NSDateExtra getDateStringWithDateString:model.currentDate currenDateFormat:@"yyyy-MM-dd" dateFormat:@"yyyy年MM月dd日"]];
    _detailLabel.text = [NSString stringWithFormat:@"%@ %@",dateStr,model.weekDay];
    _pointView.backgroundColor = HEX_RGB(@"#A7A7A7");
    
}
- (void)setIsShowDetail:(BOOL)isShowDetail{
    _isShowDetail = isShowDetail;
    _detailLabel.hidden = !isShowDetail;
}
- (void)setStatus:(NSString *)status{
    _status = status;
    
    NSInteger state = [status integerValue];
    //巡堂状态（1：正常；2：迟到；3：取消；4：异常）
    if (state == 1) {
        _titleLabel.text = @"正常";
        _titleLabel.textColor = HEX_RGB(@"#A7A7A7");
        _pointView.backgroundColor = HEX_RGB(@"#A7A7A7");
    }else if(state == 2){
        _titleLabel.text = @"迟到";
        _titleLabel.textColor = HEX_RGB(@"E93C06");
        _pointView.backgroundColor = HEX_RGB(@"E93C06");
    }else if(state == 3){
        _titleLabel.text = @"取消";
        _titleLabel.textColor = HEX_RGB(@"B9B9B9");
        _pointView.backgroundColor = HEX_RGB(@"#B9B9B9");
    }else if(state == 4){
        _titleLabel.text = @"异常";
        _titleLabel.textColor = HEX_RGB(@"E93C06");
        _pointView.backgroundColor = HEX_RGB(@"#E93C06");
    }else{
        _titleLabel.hidden = YES;
    };
    

}
- (void)setTitleString:(NSString *)titleString{
    _titleString = titleString;
    _titleLabel.text = titleString;
}



- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.titleLabel];
        [self addSubview:self.pointView];
        [self addSubview:self.detailLabel];

        [self.pointView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(5, 5));
            make.left.equalTo(self).offset(20.0f);
            make.centerY.equalTo(self);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.pointView.mas_right).offset(8.0f);
            make.centerY.equalTo(self.pointView);
        }];
        [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-20.0f);
            make.centerY.equalTo(self.pointView);
        }];


    }
    return self;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 13.0f) titleColor:HEX_RGB(@"8E8E8E") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)detailLabel {
    if (!_detailLabel) {
        _detailLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 13.0f) titleColor:HEX_RGB(@"#8E8E8E") textAlignment:ZZTextAlignmentRight];
        _detailLabel.hidden = YES;
    }
    return _detailLabel;
}

- (UIView *)pointView {
    if (!_pointView) {
        _pointView = [[UIView alloc] init];
        _pointView.layer.cornerRadius = 2.5f;
        _pointView.layer.masksToBounds = YES;
    }
    return _pointView;
}

@end
